<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
 <head>
  <meta http-equiv="content-type" content="text/html; charset=UTF-8">
  <title>Returns an array with client, protocol and server version (when available)</title>
 </head>
 <body class="docs"><div id="layout">
  <div id="layout-content"><div id="function.pg-version" class="refentry">
 <div class="refnamediv">
  <h1 class="refname">pg_version</h1>
  <p class="verinfo">(PHP 5, PHP 7)</p><p class="refpurpose"><span class="refname">pg_version</span> &mdash; <span class="dc-title">
   Returns an array with client, protocol and server version (when available)
  </span></p>

 </div>

 <div class="refsect1 description" id="refsect1-function.pg-version-description">
  <h3 class="title">说明</h3>
  <div class="methodsynopsis dc-description">
   <span class="methodname"><strong>pg_version</strong></span>
    ([ <span class="methodparam"><span class="type">resource</span> <code class="parameter">$connection</code></span>
  ] ) : <span class="type">array</span></div>

  <p class="para rdfs-comment">
   <span class="function"><strong>pg_version()</strong></span> returns an array with the client, protocol
   and server version. Protocol and server versions are only available if PHP
   was compiled with PostgreSQL 7.4 or later.
  </p>
  <p class="para">
   For more detailed server information, use <span class="function"><a href="pg_parameter_status.html" class="function">pg_parameter_status()</a></span>.
  </p>
 </div>


 <div class="refsect1 parameters" id="refsect1-function.pg-version-parameters">
  <h3 class="title">参数</h3>
  <p class="para">
   <dl>

    
     <dt>
<code class="parameter">connection</code></dt>

     <dd>

      <p class="para">
       PostgreSQL database connection resource.  When 
       <code class="parameter">connection</code> is not present, the default connection 
       is used. The default connection is the last connection made by 
       <span class="function"><a href="pg_connect.html" class="function">pg_connect()</a></span> or <span class="function"><a href="pg_pconnect.html" class="function">pg_pconnect()</a></span>.
      </p>
     </dd>

    
   </dl>

  </p>
 </div>


 <div class="refsect1 returnvalues" id="refsect1-function.pg-version-returnvalues">
  <h3 class="title">返回值</h3>
  <p class="para">
   Returns an array with <em>client</em>, <em>protocol</em> 
   and <em>server</em> keys and values (if available).  Returns
   <strong><code>FALSE</code></strong> on error or invalid connection.
  </p>
 </div>

 
 <div class="refsect1 examples" id="refsect1-function.pg-version-examples">
  <h3 class="title">范例</h3>
  <p class="para">
   <div class="example" id="example-2522">
    <p><strong>Example #1 <span class="function"><strong>pg_version()</strong></span> example</strong></p>
    <div class="example-contents">
<div class="phpcode"><pre><span style="color: #000000">
<span style="color: #0000BB">&lt;?php<br />&nbsp;&nbsp;$dbconn&nbsp;</span><span style="color: #007700">=&nbsp;</span><span style="color: #0000BB">pg_connect</span><span style="color: #007700">(</span><span style="color: #DD0000">"host=localhost&nbsp;port=5432&nbsp;dbname=mary"</span><span style="color: #007700">)<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;or&nbsp;die(</span><span style="color: #DD0000">"Could&nbsp;not&nbsp;connect"</span><span style="color: #007700">);<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<br />&nbsp;&nbsp;</span><span style="color: #0000BB">$v&nbsp;</span><span style="color: #007700">=&nbsp;</span><span style="color: #0000BB">pg_version</span><span style="color: #007700">(</span><span style="color: #0000BB">$dbconn</span><span style="color: #007700">);<br />&nbsp;&nbsp;<br />&nbsp;&nbsp;echo&nbsp;</span><span style="color: #0000BB">$v</span><span style="color: #007700">[</span><span style="color: #DD0000">'client'</span><span style="color: #007700">];<br /></span><span style="color: #0000BB">?&gt;</span>
</span>
</pre></div>
    </div>

    <div class="example-contents"><p>以上例程会输出：</p></div>
    <div class="example-contents screen">
<div class="cdata"><pre>
7.4
</pre></div>
    </div>
   </div>
  </p>
 </div>


 <div class="refsect1 seealso" id="refsect1-function.pg-version-seealso">
  <h3 class="title">参见</h3>
  <p class="para">
   <ul class="simplelist">
    <li class="member"><span class="function"><a href="pg_parameter_status.html" class="function" rel="rdfs-seeAlso">pg_parameter_status()</a> - Looks up a current parameter setting of the server</span></li>
   </ul>
  </p>
 </div>

</div></div></div></body></html>